package net.xiduth.game.npc.combat.impl;

import net.xiduth.game.Animation;
import net.xiduth.game.Entity;
import net.xiduth.game.Graphics;
import net.xiduth.game.World;
import net.xiduth.game.npc.NPC;
import net.xiduth.game.npc.combat.CombatScript;
import net.xiduth.game.npc.combat.NPCCombatDefinitions;
import net.xiduth.utils.Utils;

/**
 * 
 * @author Jae <jae@xiduth.com>
 * 
 * Last modified: <Oct 17, 2013>
 *
 */
public class AkrisCombat extends CombatScript {

	@Override
	public Object[] getKeys() {
		return new Object[] { 14297 };
	}

	@Override
	public int attack(final NPC npc, final Entity target) {
		final NPCCombatDefinitions defs = npc.getCombatDefinitions();	
		if (Utils.getRandom(2) == 0) { // range magical attack
			npc.setNextGraphics(new Graphics(2728));
			npc.setNextAnimation(new Animation(2791));
			for (Entity t : npc.getPossibleTargets()) {
				delayHit(
						npc,
						1,
						t,
						getRangeHit(
								npc,
								getRandomMaxHit(npc, 500,
										NPCCombatDefinitions.RANGE, t)));
				World.sendProjectile(npc, target, 2735, 18, 18, 50, 50, 3, 0);
				World.sendProjectile(npc, target, 2736, 18, 18, 50, 50, 20,
						0);
				World.sendProjectile(npc, target, 2736, 18, 18, 50, 50, 110,
						0);
			}
		} else { // melee attack
			npc.setNextAnimation(new Animation(defs.getAttackEmote()));
			delayHit(
					npc,
					0,
					target,
					getMeleeHit(
							npc,
							getRandomMaxHit(npc, defs.getMaxHit(),
									NPCCombatDefinitions.MELEE, target)));
		}
		return defs.getAttackDelay();
	}
}